package com.erclab.internal.xpresso.xml;

import com.erclab.internal.xpresso.exceptions.ReportColumnNotFound;
import com.erclab.internal.xpresso.forms.Form;
import com.erclab.internal.xpresso.reports.Report;

public class ObjectToXml {

	public static String createReportXML(Report report){
		StringBuffer xml = new StringBuffer();
		xml.append("<report>");
		XmlReportHelper.writeReportTags(report, xml);
		XmlReportHelper.writeFilterTags(report, xml);
		XmlReportHelper.writeColumnTags(report, xml);
		XmlReportHelper.writeReportResultSet(report, xml);
		xml.append("</report>");
		return xml.toString();
	}

	public static String createFormXML(Form theForm){
		StringBuffer xml = new StringBuffer();
		xml.append("<form>");
		XmlFormHelper.writeFormTags(theForm, xml);		
		XmlFormHelper.writeFormElementTags(theForm, xml);
		xml.append("</form>");
		return xml.toString();
	}
	
	public static String createSiteMapXml(Report report) throws ReportColumnNotFound{
		StringBuffer xml = new StringBuffer();
		SiteMapXmlHelper.createUrlItems(report, xml);
		return xml.toString();
	}
	
}
